package com.xiaoshuidi.cloud.module.iot.enums;

/**
 * Created by Arvin
 * description: 1.（sdiot平台错误码 此号以此(00090001)累加） 2.（机构错误码按照第三方）
 * date: 2018/11/23 1:35 PM
 */
public enum ErrorCodeEnum {
    CODE_INIT("0", "初始"),
    CODE_SUCCESS("1", "成功"),
    CODE_FAIL("2", "失败"),
    CODE_PROCESS("3", "处理中"),
    SYSTEM_EXCEPTION("-1", "系统异常"),
    /*修改第三方错误码中文*/
    AMOUNT_SERVICE_EXCEPTION("00090001", "账号服务异常"),
    BIZ_SERVICE_EXCEPTION("00090002", "公共业务服务异常"),
    DOORLOCK_SERVICE_EXCEPTION("00090003", "门锁服务异常"),
    AMMETER_SERVICE_EXCEPTION("00090004", "电表服务异常"),
    WATERMETER_SERVICE_EXCEPTION("00090005", "水表服务异常"),
    PASS_SERVICE_EXCEPTION("00091006","门禁服务异常"),
    SENSE_SERVICE_EXCEPTION("00091007","核验服务异常"),

    REPEAT_ADD_API("00090006", "API账号已存在"),
    INVALID_API_NO("00090007", "无效的API账号"),
    BRAND_PARTY_ACCESSTOKEN_EXCEPTION("00090008", "品牌方获取Token异常"),
    INVALID_BRAND_NO("00090009", "无效的品牌编号"),
    APINO_HADBIND_DEVICE_REFUSE_DELETE("00090010", "API账号下存在设备绑定,无法删除!"),
    ADD_DEVICE_ERROR("00090020", "该账号不存在api账号，无法拉取设备！"),

    /*内部的错误吗中文*/

    /**
     * 门锁相关错误码 区间 00095001-00095050
     */
    TIME_FORMAT_IS_ERROR("00095001", "时间格式不正确"),
    PASSWAORD_ADD_ERROR("00095002", "添加密码失败"),
    PASSWORD_UPDATE_ERROR("00095003", "密码修改失败"),
    PASSWORD_STATUS_ERROR("00095004", "密码状态不正确"),
    PASSWORD_FREEZE_ERROR("00095005", "冻结密码失败"),
    PASSWORD_RELEASE_FREEZE_ERROR("00095006", "解冻密码失败"),
    MANFGE_REDRESH_ERROR("00095007", "门锁刷新失败"),
    MOBILE_HAVE_AUTHORIZES("00095008", "手机号码已授权,不能重复授权"),
    MOBILE_AUTHORIZES_ERROR("00095009", "授权失败"),
    REMOTE_OPEN_DOORLOCK("00095010","远程开门失败"),
    PASSWAORD_PHONE_ERROR("00095011", "该手机号已下发授权"),
    /**
     * 水表相关错误码 区间 00096001-00096050
     */
    DEVICE_NO_NOT_NULL("00096001", "亲，水表设备编号不能为空!"),
    DEVICE_NO_NOT_EXIST("00096002", "亲，水表设备不存在!"),
    DEVICE_BELONG_TO_AMMETER("00096003", "亲，此设备属于电表!"),
    DEVICE_BELONG_TO_DOORLOCK("00096004", "亲，此设备属于门锁!"),
    HOT_WATERMETER_TOPUP_NOT_ALLOWD("00096005", "热水表不允许充值!"),
    WATERMETER_PRICE_NOT_ZERO("00096006", "水表单价不允许为0!"),

    /**
     * 电表相关错误码 00097001 - 00097050
     */
    AMMETER_NO_NOT_EXIST("00097001", "电表设备不存在"),

    AMMETER_PRICE_NOT_ZERO("00097002", "电表单价不允许为0"),

    /**
     * 门禁相关错误码 00098001-00098050
     */
    PASS_IDNUMBER_NOT_REPEAT("00098001","门禁人员身份证不能重复"),
    PASS_NO_NOT_EXIST("00098002","门禁人员不存在"),
    PASS_ADD_MEMBER_ONE("00098003","请至少先添加一位员工");

    private String code;
    private String msg;

    ErrorCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ErrorCodeEnum getEnumByKey(String key) {
        if (null == key) {
            return null;
        }
        for (ErrorCodeEnum temp : ErrorCodeEnum.values()) {
            if (temp.getCode().equals(key)) {
                return temp;
            }
        }
        return null;
    }
}
